package model.core;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import model.area_effect.MapAreaOfEffect;
import model.area_effect.Trap;
import model.entity.Avatar;
import model.entity.DirectionalGraphicSet;
import model.entity.Entity;
import model.entity.MovementType;
import model.entity.Smasher;
import model.item.InventoryItem;
import model.map.GameMap;
import model.map.MapPoint;
import model.map.ViewMap;
import model.stats.StatsContainer;

public abstract class Instantiator {
	private Avatar avatar = new Smasher(); //DEFAULT
	private String loadFile;
	
	public void placeItems(GameMap map){
		PlacementParser parser = new PlacementParser(loadFile);
		
		HashMap<MapPoint, List<InventoryItem>> items = new HashMap<MapPoint, List<InventoryItem>>();
		HashMap<MapPoint, List<MapAreaOfEffect>> aoes = new HashMap<MapPoint, List<MapAreaOfEffect>>();
		HashMap<MapPoint, List<Trap>> traps = new HashMap<MapPoint, List<Trap>>();
		HashMap<MapPoint, List<Entity>> entities = new HashMap<MapPoint, List<Entity>>();
		try{
			items = parser.parseItemsMap();
			aoes = parser.parseAoEMap();
			traps = parser.parseTrapMap();
			entities = parser.parseEntityMap();
		}
		catch(IOException e){
			e.printStackTrace();
		}
		//avatar.setLocation(new MapPoint(4,4));
		ArrayList<Entity> av = new ArrayList<Entity>();
		av.add(avatar);
		
		entities.put(avatar.getLocation(), av);
		map.buildItemMap(items);
		map.buildMapAreaOfEffectMap(aoes);
		map.buildTrapMap(traps);
		map.buildEntityMap(entities);
	}
	
	public ViewMap initializeViewMap(GameMap map){
		MapPoint dim = map.getBoundary();
		System.out.println(dim.toString());
		ViewMap vMap = new ViewMap(dim.getXCoordinate(),dim.getYCoordinate(), "blackTile", avatar);
		return vMap;
	}
	
	public void setAvatar(Avatar a){
		this.avatar = a;
	}
	public void setLoadFile(String l){
		this.loadFile = l;
	}
	public Avatar getAvatar(){
		return avatar;
	}
}
